package org.grottarossa.tms.ui.console;

import java.io.Serializable;

import org.grottarossa.tms.aeroflow.ui.core.viewmanager.ViewManagerBase;

import com.vaadin.ui.Component;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.Window;


/**
 * Implementazione di IViewManager che visualizza tutte le view all'interno di un {@link com.vaadin.ui.ComponentContainer contenitore Vaadin} specificato, una alla volta.
 *
 * @author 
 */
public class DetailViewManager extends ViewManagerBase implements Serializable
{
	private static final long serialVersionUID = 1326282755700865304L;

	private ComponentContainer m_targetContainer;

	/**
	 * @param container {@link com.vaadin.ui.ComponentContainer contenitore Vaadin} in cui visualizzare le view
	 */
	public DetailViewManager(ComponentContainer container)
	{
		m_targetContainer = container;
	}

	@Override
	public void exitView(Component view)
	{
		m_targetContainer.removeAllComponents();
	}

	@Override
	public Window enterView(Component view)
	{
		m_targetContainer.removeAllComponents();
		m_targetContainer.addComponent(view);
		return m_targetContainer.getWindow();
	}
}
